COMMAND_PREFIX = '/'
VERSION = '0.9'
REVISION = 'BT20071211'

class ICommand:
    def __init__(self):
        self._command = ''
        self._desc = ''
        self._isAdmin = False
    
    def getCommand(self):
        return self._command
    def getDesc(self):
        return self._desc
    def isAdmin(self):
        return self._isAdmin

    def execute(self, who, msg):
        raise Exception("%s's command %s cannot executed!" % (who, msg))

class IACommand(ICommand):
    def __init__(self, command, desc):
        self._command = ''
        self._desc = ''
        self._isAdmin = True

class CmdVersion(ICommand):
    def __init__(self):
        self._command = 'ver'
        self._desc = '"%s%s" Show version of this bot'

    def execute(self, who, msg=''):
        ret = 'VER: %s (%s)' % (VERSION, REVISION)
        return {who:ret, 'other':''}

if __name__ == "__main__":
    import unittest

    class TestCommand(unittest.TestCase):
        def testCmdVersion(self):
            cmd = CmdVersion()
            result = cmd.execute('ch.linghu')
            self.assertEqual(result['ch.linghu'], 'VER: 0.9 (BT20071211)')

    unittest.main()
